import request from '@/utils/request'
import { MD5 } from '@/utils/SHA';

// 获取图形验证码
export function GetGraphicVerificationCode() {
  return request({
    headers: {
      withoutToken: true
    },
    url: '/api/auth/code',
    method: 'get'
  });
}

// 后台用户登录
export function GetToken(username, password, key, code) {
  const data = new FormData()
  data.append('grant_type', 'captcha')
  data.append('scope', 'all')
  data.append('username', username)
  data.append('password', MD5(password))

  return request({
    headers: {
      'Content-Type': ' application/x-www-form-urlencoded ',
      'key': key,
      'code': code
    },
    url: `/api/oauth/token`,
    method: 'post',
    data: data
  })
}

//  更改菜单按钮
export function getRouteData() {
  return request({
    headers: {
      'Content-Type': ' application/json'
    },
    url: '/api/menu/change-menu',
    method: 'post',
    data: { application: 'report_platform' } // 应用类型 需要修改成 ‘united_front’
  })
}

//  首页获取接口数据
export function GetHomeList(data) {
  return request({
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
      withoutToken: true
    },
    url: '/api/contentnotice/info',
    method: 'post',
    data: data
  })
}

//  登出
export function Logout() {
  return request({
    headers: {
      'Content-Type': ' application/json'
    },
    url: '/api/auth/logout',
    method: 'post'
  })
}
